import js from '@eslint/js'
import globals from 'globals'
import pluginVue from 'eslint-plugin-vue'
import { defineConfig } from 'eslint/config'
import prettierPlugin from 'eslint-plugin-prettier'
import prettierConfig from 'eslint-config-prettier'
export default defineConfig([
  {
    files: ['**/*.{js,mjs,cjs,vue}'],
    plugins: { js, prettier: prettierPlugin },
    extends: ['js/recommended'],
    languageOptions: {
      globals: globals.browser,
    },
    rules: {
      semi: 'error', // 强制分号，违反时报错
      'prefer-const': 'error', // 强制用 const 声明未修改的变量
      'no-console': 'error',
      'prettier/prettier': 'error', //规范prettier规则报error
    },
    ignores: ['dist', 'node_modules', 'public/*', 'src/assets/*'],
  },
  pluginVue.configs['flat/essential'],
  prettierConfig, //放在最后，后面的配置项拥有更高优先级，可以覆盖前面的规则
])
